package model;

import java.awt.Color;
import java.lang.reflect.Field;
import java.util.ArrayList;

public class Cell {
	int price; //price of the cell
	String name;//name of the cell
	String kindOfCell;//kind of the cell
	Color colour;//colour of the cell
	ArrayList<Player> p;//list of players on this cell
	Player owner;//owner of the cell
	Player bank = new Player("bank", null);//just to give a owner "player" to the cell
	int nbHouse;
	//constructor, empty, I'll set the values with setters. Too much different cells.
	public Cell (){
		name="";
		price=0;
		kindOfCell="";
		colour=null;
		p=new ArrayList<Player>();
		owner =null;
		nbHouse=0;
	}

	//return the kind of the Cell
	public String getKindCell(){
		return kindOfCell;
	}

	//return name of the Cell
	public String getName(){
		return name;
	}

	//return colour
	public Color getColour(){
		return colour;
	}
	
	//return price
	public int getPrice(){
		return price;
	}
	
	//return a list of the players
	public ArrayList<Player> getPlayer(){
		return p;
	}
	
	//return the owner of the cell
	public Player get_owner(){
		return owner;
	}
	
	//return the number of houses, 5 for one hotel
	public int getNbHouses(){
		return nbHouse;
	}
	
	//setter
	//value for the go
	public void setGo(){
		name = "Go";
		kindOfCell="go";
	}
	
	//we set the number of house of this cell.
	public void setHouse(int nbHouse){
		this.nbHouse=nbHouse;
	}


	//values for cities
	public void setCity(String n, int p, String col ) {
		name = n;
		price = p;
		Field field;
		Color color=null;
		if(col.equals("station") || col.equals("utility")){
			color=Color.white;
			if(col.equals("station"))
			kindOfCell="station";
			else kindOfCell="utility";
		}
		else{
			try {
				field = Class.forName("java.awt.Color").getField(col);
				color = (Color)field.get(null);
			} catch (Exception e) {e.printStackTrace();}
		colour = color;
		kindOfCell = "city";
		}
		owner=bank;//all cards are own by the bank
	}

	//values for community chest
	public void setCommunity_chest(){
		name = "Community Chest";
		kindOfCell="community_chest";
	}

	//set a Chance cell
	public void setChance(){
		name = "Chance";
		kindOfCell="chance";
	}

	//set a free parking cell
	public void setFreeParking(){
		name = "freeParking";
		kindOfCell="free_parking";
	}

	//set a Tax cell
	public void setTax(String n, int fee){
		name = n;
		kindOfCell="tax";
		price= fee;
	}
	
	//set a gotojail cell
	public void setGoToJail(){
		name="goToJail";
		kindOfCell="go_to_jail";
	}

	//set a jail cell
	public void setJail(){
		name="jail";
		kindOfCell="jail";
	}
	
	//set a list of the players
	public void setPlayer(ArrayList<Player> player){
		for(int i=0;i<player.size();i++){
			p.add(player.get(i));
		}
	}
	public void set_owner(Player p){
		owner = p;
	}
}
